package com.zgf.easy.proxy.demo.implb.user;

import com.zgf.easy.proxy.anno.AutoService;
import com.zgf.easy.proxy.demo.extend.user.UserExtendApi;
import com.zgf.easy.proxy.demo.extend.user.mode.UserReq;
import com.zgf.easy.proxy.demo.extend.user.mode.UserRes;
import com.zgf.easy.proxy.demo.implb.bean.TestbBeanService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.AsyncResult;

import java.util.concurrent.Future;

@Slf4j
@AutoService(value = "userExtendApiImplB")
public class UserExtendApiImpl  implements UserExtendApi {

    @Autowired
    private TestbBeanService testbBeanService;

    /**
     * easy_proxy必须配置异步化线程池且返回Future，否则同步调用
     * @param req
     * @return
     */
    @Override
    public Future<UserRes> getUser(UserReq req) {
        UserRes res = new UserRes();
        res.setName(req.getName());
        log.info("implb-UserExtendApiImpl.getUser={}", res);
        testbBeanService.test();
        return AsyncResult.forValue(res);
    }
}
